package cn.webrx;

import java.util.Arrays;

public class Arr23 {
    public static void main(String[] args) {
        Student[] ss = new Student[]{
                new Student(11,"李四",60),
                new Student(22,"赵强",50),
                new Student(122,"王强",85),
                new Student(322,"周勇",15),
                new Student(32,"王三",98),
                new Student(33,"张三丰",80)
        };

        System.out.println(Arrays.toString(ss));

        //根据学生的成绩降序,sort() 排序要对对象排序，对象类 必须实现比较器接口。
        Arrays.sort(ss);
        System.out.println(Arrays.toString(ss));

        //根据学生的成绩升序
        Arrays.sort(ss,(a,b)->a.getScore()-b.getScore());
        System.out.println(Arrays.toString(ss));

        //根据姓名降序
        Arrays.sort(ss,(a,b)->a.getName().compareTo(b.getName()));
        System.out.println(Arrays.toString(ss));
    }
}
